﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Private_NoPromotion.Master" Inherits="System.Web.Mvc.ViewPage" %>

<%@ Import Namespace="WebHoiChoMuaBan.Controllers.Helpers" %>
<%@ Import Namespace="WebHoiChoMuaBan.Models" %>
<%@ Import Namespace="WebHoiChoMuaBan.Controllers.Utility" %>

<asp:Content ID="Content2" ContentPlaceHolderID="TitleHolder" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HeadHolder" runat="server">
    <style type="text/css">
        .gap {margin-bottom:15px;}
        .font_bold{text-align:left;}
    </style>
    <script type="text/javascript">
        jQuery(document).ready(function () {
            highLightPrivateChildMenu('<%=ViewData["mid"] %>');
            
            // Check and Uncheck all combobox
            $("#checkbox_all").click(function () {
                var n = $("#checkbox_all:checked").length;
                if (n == 1) {
                    $(".input_checkbox:not(#checkbox_news,#checkbox_member,#checkbox_product)").attr('checked', true);
                }
                else
                    $(".input_checkbox:not(#checkbox_news,#checkbox_member,#checkbox_product)").attr('checked', false);
            });
        });

        
        
    </script>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContentHolder" runat="server">
    <div class="private_share_post_top gap" >
        <div class="private_sharepost_menu">
            <ul>
                <li><a href="<%= Url.Action("Index","Product", new { uid = Session["MemId"]} ) %>" id="childmenu_posting">Đăng sản phẩm</a></li>
                <li><a href="<%= Url.Action("ListToModify","Product", new { uid = Session["MemId"], p = 1} ) %>" id="childmenu_editing">Chỉnh sửa sản phẩm</a></li>
            </ul>
        </div>
    </div>
        <form action="<%= Url.Action("Controller","Product") %>" method="post" enctype="multipart/form-data" id="frm_News">
        <input type="hidden" id="hidCmd" name="hidCmd" />
        <div class="col_left hoicho_marin_leftright content_right">
            <div class="content_group">
                <div class="col_left content_group hoicho_margin_topbottom" >
                    <div class="private_button_upload col_left hoicho_margin_leftright">
                        <a href="javascript:void(0)" onclick="SubmitData_Ajax('frm_News', 'del'); return false;" name="Delete">
                            <img src="<%=ResolveUrl("~/Content/Images/icon_plus_up.gif") %>" alt=""/>Xóa
                        </a>
                    </div>
                    <div class="private_button_upload col_left hoicho_margin_leftright">
                        <a href="javascript:void(0)"><img src="<%=ResolveUrl("~/Content/Images/icon_plus_up.gif") %>" alt=""/>
                        Cắt</a>
                    </div>
                    <div class="private_button_upload col_left hoicho_margin_leftright">
                        <a href="javascript:void(0)"><img src="<%=ResolveUrl("~/Content/Images/icon_plus_up.gif") %>" alt=""/>
                        Dán</a>
                    </div>
                    <div class="private_button_upload col_left">
                        <a href="javascript:void(0)" onclick="SubmitData_Ajax('frm_News','ChangeState'); return false;" name="ChangeState"><img src="<%=ResolveUrl("~/Content/Images/icon_plus_up.gif") %>" alt=""/>
                        Chuyển trạng thái</a>
                    </div>
                    <div class="col_left hoicho_margin_leftright font_bold" style="float:right">
                        <%
                            NewsProductHelper.FetchProductResult lstNews = (NewsProductHelper.FetchProductResult)ViewData["ListNewsProduct"];
                            int p = 1;
                            if (Request.QueryString["p"] != null && int.TryParse(Request.QueryString["p"], out p))
                            {
                             %>
                        <% if (p > 1) { %><a href='<%=string.Format("{0}?p={1}'",
                                                                Url.Action("ListToModify", "Product", new { uid = Session["Memid"] }),
                                                                p-1) %>'><img src="/../Content/Images/arrow_breakpage_left.gif" alt="">&nbsp;Trang trước</a> <% } %>
                        <%
                            for (int i = 1; i <= lstNews.totalPages; i++)
                                Response.Write(string.Format("<a href='{0}?p={1}' {2}>{3}</a> ",
                                                                Url.Action("ListToModify", "Product", new { uid = Session["Memid"] }),
                                                                i,
                                                                (i == p ? "style='color:#8A1903'" : string.Empty),
                                                                 i));
                         %>
            
                        <% if (p < lstNews.totalPages) { %><a href='<%=string.Format("{0}?p={1}'",
                                                                Url.Action("ListToModify", "Product", new { uid = Session["Memid"] }),
                                                                p+1) %>'>Trang sau&nbsp;<img src="/../Content/Images/arrow_breakpage_right.gif" alt=""></a> <% } %>
                        <% }  %>
                    </div>
                    <!-- LƯU LẠI DẤU CỦA TRANG ĐANG HIỂN THỊ ĐỂ DÙNG TRONG VIỆC LƯU VẾT KHI XÓA-->
                    <input type="hidden" id="currPage" name="currPage" value="<%= p %>" />
                </div>
            </div>
            
            <div class="private_group_friend" style="margin-top:5px;">
                <table width="100%" border="0">
                    <tr bgcolor="#f5f7fb" class="border_bottom">
                        <th width="3%"><input id="checkbox_all" class="input_checkbox" type="checkbox" name="checkbox_all"/></th>
                        <th width="59%"><p class="font_bold" for="checkbox5">Nội dung</p></th>
                        <th width="8%"><span class="font_bold">Trạng thái</span></th>
                        <th width="9%" align="center">Ngày gửi</th>
                        <th width="11%">&nbsp;</th>
                    </tr>
                    <%
                      if (ViewData["ListNewsProduct"] != null)
                        {
                            NewsProductHelper.FetchProductResult lstNewsProduct = (NewsProductHelper.FetchProductResult)ViewData["ListNewsProduct"];
                            int j = 0;
                            if (lstNewsProduct.products.Count > 0)
                            {
                                foreach (var item in lstNewsProduct.products)
                                {
                                    if (j++ % 2 == 0)
                                        Response.Write("<tr>");
                                    else
                                        Response.Write("<tr bgcolor='#e6e6e6'>");
                                    Response.Write("<td><input id='checkbox" + item.NProId + "' class='input_checkbox' type='checkbox' name='checkbox' value='" + item.NProId + "'/></td>");
                                    Response.Write("<td><span class='font_bold'>" + item.NProTitle + "</span></td>");
                                    Response.Write("<td align='center'><span>" + (item.NProState == true ? "Xuất bản" : "Chờ") + "</span></td>");
                                    Response.Write("<td align='center'><span class='font_bold'>" + item.NProDate.ToString("dd/MM/yyyy") + "</span></td>");
                                    Response.Write("<td align='right'><div class='private_button_upload col_right'>");
                                    Response.Write("<a href='/Product/DeleteProduct?uid=" + item.MemId + "&productId=" + item.NProId + "&currPage=" + p + "'><img src='/../Content/Images/icon_plus_up.gif'/>Xóa</a></div>");
                                    Response.Write("<div class='private_button_upload col_right hoicho_margin_leftright'>");
                                    Response.Write("<a href='/Product/LoadToEditProduct?uid=" + item.MemId + "&productId=" + item.NProId +"'><img src='/../Content/Images/icon_plus_up.gif'/>Sửa</a></div></td>");
                                }
                            }
                            else
                            {
                                Response.Write("<tr><td colspan='5'>Không có dữ liệu </td></tr>"); 
                            }
                        }
                    %>
                </table>
                <br />
            </div>
            <div class="content_group">
                <div class="col_left content_group hoicho_margin_topbottom gap">
                    <div class="private_button_upload col_left hoicho_margin_leftright">
                        <a href="javascript:void(0)" onclick="SubmitData_Ajax('frm_News', 'del'); return false;" name="Delete">
                            <img src="<%=ResolveUrl("~/Content/Images/icon_plus_up.gif") %>" alt=""/>Xóa
                        </a>
                    </div>
                    <div class="private_button_upload col_left hoicho_margin_leftright">
                        <a href="javascript:void(0)"><img src="<%=ResolveUrl("~/Content/Images/icon_plus_up.gif") %>" alt=""/>
                        Cắt</a>
                    </div>
                    <div class="private_button_upload col_left hoicho_margin_leftright">
                        <a href="javascript:void(0)"><img src="<%=ResolveUrl("~/Content/Images/icon_plus_up.gif") %>" alt=""/>
                        Dán</a>
                    </div>
                    <div class="private_button_upload col_left">
                        <a href="javascript:void(0)" onclick="SubmitData_Ajax('frm_News','ChangeState'); return false;" name="ChangeState"><img src="<%=ResolveUrl("~/Content/Images/icon_plus_up.gif") %>" alt=""/>
                        Chuyển trạng thái</a>
                    </div>
                    <div class="col_left hoicho_margin_leftright font_bold" style="float:right">
                        <%
                            if (Request.QueryString["p"] != null && int.TryParse(Request.QueryString["p"], out p))
                            {
                             %>
                        <% if (p > 1) { %><a href='<%=string.Format("{0}?p={1}'",
                                                                Url.Action("ListToModify", "Product", new { uid = Session["Memid"] }),
                                                                p-1) %>'><img src="/../Content/Images/arrow_breakpage_left.gif" alt="">&nbsp;Trang trước</a> <% } %>
                        <%
                            for (int i = 1; i <= lstNews.totalPages; i++)
                                Response.Write(string.Format("<a href='{0}?p={1}' {2}>{3}</a> ",
                                                                Url.Action("ListToModify", "Product", new { uid = Session["Memid"] }),
                                                                i,
                                                                (i == p ? "style='color:#8A1903'" : string.Empty),
                                                                 i));
                         %>
            
                        <% if (p < lstNews.totalPages) { %><a href='<%=string.Format("{0}?p={1}'",
                                                                Url.Action("ListToModify", "Product", new { uid = Session["Memid"] }),
                                                                p+1) %>'>Trang sau&nbsp;<img src="/../Content/Images/arrow_breakpage_right.gif" alt=""></a> <% } %>
                        <% }  %>
                    </div>
                </div>
            </div>
        </div>
    </form>
</asp:Content>
